package com.cenwangkeji.zhihuimuye.ui.activity;

import android.Manifest;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.MediaController;
import android.widget.VideoView;

import com.cenwangkeji.zhihuimuye.R;
import com.lws.basic.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.RuntimePermissions;

@RuntimePermissions
public class VideoActivity extends BaseActivity {


    @BindView(R.id.vv)
    VideoView mVv;


    @Override
    public int setLayoutId() {
        return R.layout.activity_video;
    }

    @Override
    public void initData() {
        super.initData();
        ButterKnife.bind(this);

        VideoActivityPermissionsDispatcher.playWithCheck(this);

    }

    @NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
    void play() {
        MediaController localMediaController = new MediaController(this);
        mVv.setMediaController(localMediaController);
        String uri = ("android.resource://" + getPackageName() + "/" + R.raw.v);
        mVv.setVideoURI(Uri.parse(uri));
        mVv.start();

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

}
